import React,{ Component } from "react";


export default class Hello extends Component {
    state = {
        lists: [

        ]
    }

    getHotLists = () => {
        fetch("http://59.110.226.77:3000/api/list/hot?cid=17").then(res => res.json()).then(data => {
            // console.log("data:", data);
            const {data: {content}} = data
            this.setState({
                lists: content
            })
        }).catch(error => Promise.reject(error))
    }

    renderLists = () => {
        if(this.state.lists.length == 0) return <div>加载中。。。</div>
        return this.state.lists.map(item => <li key={item.id}>
            <img width="80" height="80" src={item.pic} />
            <h3>{item.d_title}</h3>
        </li>)
    }

    render() {
        let {lists} = this.state
        return (
            <div>
                <button onClick={this.getHotLists}>人气</button>
                <button>罪行</button>
                <button>销量</button>
                <button>价格</button>

                <ul>
                {this.renderLists()}
                </ul>
            </div>
        )
    }
}

// export default function Hello() {
  

//     return (
//         <div>
          
//         </div>
//     )
// }